package vns.server.domain;

import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

import vns.shared.RuleSetDTO;

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class RuleSet {
	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Key id;
	@Persistent
	private String name;
	@Persistent
	private int poriodictime;
	@Persistent
	private Date begintime;
	@Persistent
	private Date endtime;
	@Persistent
	private String actionKey;
	@Persistent()
	private String conditionExp;
	@Persistent()
	private String oTypeKey;
	@Persistent()
	private String ruleType;
	@Persistent
	private String describe;

	public RuleSet(RuleSetDTO rulesetDTO) {
		this.name = rulesetDTO.getName();
		this.poriodictime = rulesetDTO.getPoriodicTime();
		this.begintime = rulesetDTO.getBeginTime();
		this.endtime = rulesetDTO.getEndTime();
		this.actionKey = rulesetDTO.getActionKey();
		this.conditionExp = rulesetDTO.getConditionExp();
		this.oTypeKey = rulesetDTO.getoTypeKey();
		this.ruleType = rulesetDTO.getRuleType();
		this.describe = rulesetDTO.getDescribe();
	}

	public void updatefromDTO(RuleSetDTO rulesetDTO) {
		this.name = rulesetDTO.getName();
		this.poriodictime = rulesetDTO.getPoriodicTime();
		this.begintime = rulesetDTO.getBeginTime();
		this.endtime = rulesetDTO.getEndTime();
		this.actionKey = rulesetDTO.getActionKey();
		this.conditionExp = rulesetDTO.getConditionExp();
		this.oTypeKey = rulesetDTO.getoTypeKey();
		this.ruleType = rulesetDTO.getRuleType();
		this.describe = rulesetDTO.getDescribe();
	}

	public RuleSetDTO toDTO() {
		RuleSetDTO rulesetDTO = new RuleSetDTO(this.id, this.name,
				this.poriodictime, this.begintime, this.endtime,
				this.actionKey, this.conditionExp, this.oTypeKey,
				this.ruleType, this.describe);
		return rulesetDTO;
	}

	public Key getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String Name) {
		this.name = Name;
	}

	public int getPoriodicTime() {
		return poriodictime;
	}

	public void setPoriodicTime(int Poriodictime) {
		this.poriodictime = Poriodictime;
	}

	public Date getBeginTime() {
		return begintime;
	}

	public void setBeginTime(Date Begintime) {
		this.begintime = Begintime;
	}

	public Date getEndTime() {
		return endtime;
	}

	public void setEndTime(Date Endtime) {
		this.endtime = Endtime;
	}

	public String getDescribe() {
		return describe;
	}

	public void setDescribe(String Describe) {
		this.describe = Describe;
	}

	public void setActionKey(String actionKey) {
		this.actionKey = actionKey;
	}

	public String getActionKey() {
		return actionKey;
	}

	public void setConditionExp(String conditionExp) {
		this.conditionExp = conditionExp;
	}

	public String getConditionExp() {
		return conditionExp;
	}

	public void setoTypeKey(String oTypeKey) {
		this.oTypeKey = oTypeKey;
	}

	public String getoTypeKey() {
		return oTypeKey;
	}

	public void setRuleType(String ruleType) {
		this.ruleType = ruleType;
	}

	public String getRuleType() {
		return ruleType;
	}
}